<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('sysevent','list');
$starttimer = microtime(true);
$checkPagenum = isset($checkPagenum) ? $checkPagenum : $cfg_pagenum; 
 ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>操作日志</title>

<link href="templates/css/style.css" rel="stylesheet" type="text/css" />
<link href="templates/css/pagination.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
<script type="text/javascript" src="templates/js/forms.func.js"></script>
<script type="text/javascript" src="plugin/calendar/calendar.js"></script>
</head>
<body class="mainbody">
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <span>操作日志</span>
  <a href="javascript:location.reload();" class="reload">刷新</a>
</div>
<!--工具栏-->
<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"></a>
	      <div class="r-list" style="position:static;float:left;">
	<form name="form" id="form" method="" action="" style="display:inline;">
	
        <input name="uname" type="text" id="uname" class="keyword" />
        <input  class="btn-search" type="submit" value="搜索" style="cursor:pointer;">
			  &nbsp;&nbsp;
						操作时间：
						<input type="text" name="starttime" id="starttime" class="input rule-date-input" value="<?php echo GetDateTime(time()-2592000); ?>" readonly="readonly" />
						~
						<input type="text" name="endtime" id="endtime" class="input rule-date-input" value="<?php echo GetDateTime(time()); ?>" readonly="readonly" />
						<script type="text/javascript">
						Calendar.setup({
							inputField     :    "starttime",
							ifFormat       :    "%Y-%m-%d %H:%M:%S",
							showsTime      :    true,
							position       :    [233, 100],
							timeFormat     :    "24"
						});
						
						Calendar.setup({
							inputField     :    "endtime",
							ifFormat       :    "%Y-%m-%d %H:%M:%S",
							showsTime      :    true,
							position       :    [421, 100],
							timeFormat     :    "24"
						});
						</script> 
	  </form>
      </div>
      <div class="l-list">

        &nbsp;&nbsp;操作站点：
		<div class="rule-single-select">
		<select name="siteid" onchange="func('siteid')" id="siteid">
				<option value="0"> 全部 </option>
							<?php
							$dosql->Execute("SELECT `id`,`sitename` FROM `#@__site` ORDER BY `id` ASC");
							while($row = $dosql->GetArray())
							{
								if(!empty($siteid) && $siteid==$row['id'])
									$selected = 'selected="selected"';
								else
									$selected = '';
								
								echo '<option value="'.$row['id'].'" '.$selected.'>'.$row['sitename'].'</option>';
							}
						?>
		</select>
         </div>&nbsp;&nbsp;
						操作类型：
		  <div class="rule-single-select">
		 <select name="action" onchange="func('action')" id="action">
						<option value=""> 全部 </option>
							<option value="add" <?php if(!empty($action) && $action=='add') echo 'selected="selected"';?>> 添加 </option>
							<option value="update" <?php if(!empty($action) &&$action=='update') echo 'selected="selected"';?>> 修改 </option>
							<option value="del" <?php if(!empty($action) &&$action=='del') echo 'selected="selected"';?>> 删除 </option>
		</select>
          </div>
		
      </div>
     
    </div>
  </div>
</div>
<!--/工具栏-->

<!--列表-->
<div class="table-container">

  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>
		<th >选择</th>
	
		<th >标题</th>
		
    </tr>
  
	<?php
	$sql = "SELECT * FROM `#@__sysevent` WHERE `id`<>0";
	
	if(!empty($uname))
		$sql .= " AND `uname`='$uname'";
	if(!empty($siteid))
		$sql .= " AND `siteid`=$siteid";
	if(!empty($action))
		$sql .= " AND `action`='$action'";
	if(!empty($starttime))
		$sql .= " AND `posttime`>=".GetMkTime($starttime);
	
	if(!empty($endtime))
		$sql .= " AND `posttime`<=".GetMkTime($endtime);

    $dopage->GetPage($sql,30);
	while($row = $dosql->GetArray())
	{
		$r = $dosql->GetOne("SELECT `sitename` FROM `#@__site` WHERE `id`=".$row['siteid']);
		if(isset($r) && is_array($r))
		{
			$sitename=$r['sitename'];
			
		}
		else{
			$sitename='<span style="text-decoration:line-through;">已删除站点</span>';
		}
		if($row['model'] == 'login')
		{
	?>
	<tr>
		<td ><span class="padl10"> <span class="number"><?php echo GetDateTime($row['posttime']); ?></span>：</span> 用户 <strong><?php echo $row['uname']; ?></strong> 进行了 <span class="blue">登录操作</span></td>
		<td width="120">记录IP：<?php echo $row['ip']; ?></td>
	</tr>
	<?php
		}

		else if($row['model'] == 'logout')
		{
	?>
	<tr >
		<td><span class="padl10"> <span class="number"><?php echo GetDateTime($row['posttime']); ?></span>：</span> 用户 <strong><?php echo $row['uname']; ?></strong> 进行了 <span class="blue">退出操作</span></td>
		<td width="120">记录IP：<?php echo $row['ip']; ?></td>
	</tr>

	<?php
		}
		else
		{	
		require_once(ADMIN_INC.'/actionType.php');
		foreach($actionType2 as $i => $value)
		{		
		
			if($i==$row['action'])
				{
					$action= $value;
				}
		}
		if(!isset($action)){
			
			$action= $row['action'];
		}
		//
		if(empty($row['class']))
		{
			
			$class=$row['model'];
		}
		else{
				$class=$row['class'];
			
		}
		if($row['classid'] != 0 )
		{
			$r2 = $dosql->GetOne("SELECT `classname` FROM `#@__infoclass` WHERE `id`=".$row['classid']);
			if(isset($r2['classname']))
			$class=$r2['classname'];
			else
			$class = '<span class="red">栏目分类['.$row['classid'].']</span>';
			
		}
	?>
	<tr >
		<td ><span class="padl10"> <span class="number"><?php echo GetDateTime($row['posttime']); ?></span>：</span> 用户 <strong><?php echo $row['uname']; ?></strong> 在 <span class="maroon2"><?php echo $sitename; ?></span> <?php echo $action; ?>了 <span class="blue"><?php echo $class; ?>:<?php echo $row['title']; ?></span></td>
		<td width="120">记录IP：<?php echo $row['ip']; ?></td>
	</tr>
	

	<?php
		}
	}
	$stoptimer = microtime(true);
	?>
 <?php

//判断无记录样式
if($dosql->GetTotalRow() == 0)
{
	echo '<tr><td align="center" colspan="8">暂无记录</td></tr>';
}
?>
  </table>

</div>
<!--/列表-->

<!--内容底部-->
<div class="line20"></div>
<div class="pagelist">

  <?php echo $dopage->GetList($sql,$checkPagenum); ?>
  <div class="l-btns"><span>
<?php 

$timer = $stoptimer-$starttimer;
echo " $timer s";?></span>
</div>
</div>
<!--/内容底部-->
</form>
</body>
</html>